What a stochastic model allows:
Compartmental model flow diagram
\[ \begin{align*} dS/dt &= -\beta S(I+A)\\ dE/dt &= \beta S(I+A) - \tfrac{1}{d_{EI}}E\\ dA/dt &= \tfrac{1-r}{d_{EI}}E - \tfrac{1}{d_{IR}}A\\ dI/dt &= \tfrac{r}{d_{EI}}E - (\tfrac{\alpha}{d_{IH}}\tfrac{1-\alpha}{d_{IR}})I\\ dH/dt &= \alpha (\tfrac{\alpha}{d_{IH}}\tfrac{1-\alpha}{d_{IR}})I - (\tfrac{\kappa}{d_{HQ}}\tfrac{1-\kappa}{d_{HR}})H \\ dQ/dt &= \kappa (\tfrac{\kappa}{d_{HQ}}\tfrac{1-\kappa}{d_{HR}})H - (\tfrac{\delta}{d_{QD}}\tfrac{1-\delta}{d_{QR}})Q \\ dV/dt &= p_V Q\\ dD/dt &= \delta (\tfrac{\delta}{d_{QD}}\tfrac{1-\delta}{d_{QR}})Q\\ dR/dt &= (1-\alpha) (\tfrac{\alpha}{d_{IH}}\tfrac{1-\alpha}{d_{IR}})I + (1-\kappa) (\tfrac{\kappa}{d_{HQ}}\tfrac{1-\kappa}{d_{HR}})H + (1-\delta)(\tfrac{\delta}{d_{QD}}\tfrac{1-\delta}{d_{QR}})Q + \tfrac{1}{d_{IR}}A \ \end{align*} \]
\[ R0 = \beta ({\frac{r}{\tfrac{\alpha}{d_{IH}}+\tfrac{1-\alpha}{d_{IR}}}+ (1-r){d_{IR}}}) \\ N=S+E+A+I+H+Q+D+R \]
| Parameter | Description | Value |
|---|---|---|
| \(R0\) | Basic reproductive number | Estimated |
| \(\beta\) | transmission rate | Analytically derived from model and R0 |
| \(d_{EI}\) | days between exposure and infectivity (incubation period) | 5 days |
| \(d_{IH}\) | days between symptom onset and hospitalization (if required) | 10 days |
| \(d_{IR}\) | days between symptom onset and recovery (if not hospitalized) | 7 days |
| \(d_{HQ}\) | days between hospitalization and ICU (if required) | 1 days |
| \(d_{QR}\) | days between hospitalization and recovery (if ICU not required) | 12 days |
| \(d_{QD}\) | days between ICU and fatality | 8 days |
| \(d_{QR}\) | days between ICU and recovery | 7 days |
| \(\alpha\) | probability infected (I) requires hospitalization (vs. recovers) | Estimated |
| \(\kappa\) | probability hospitalized (H) requires ICU (vs. recovers) | Estimated |
| \(\delta\) | probability ICU (Q) patient dies | Estimated |
| \(p_V\) | probability ventilation (V) required given ICU | Estimated |
| \(N\) | Total population size | |
| \(S\) | Susceptible population | |
| \(E\) | Exposed not yet infectious | |
| \(A\) | Infected, unobserved | |
| \(I\) | Infected, observed | |
| \(H\) | In Hospital | |
| \(Q\) | In ICU | |
| \(V\) | On ventilator | |
| \(D\) | Dead | |
| \(R\) | Recovered/removed |
In this section we focus on parameter estimates for key epidemic and model quantities:
| R0 | Prop. cases observed | Start time | R0 reduction | Pr(Death) | Pr(Hospital) | Pr(ICU) | Pr(Ventilation) | |
|---|---|---|---|---|---|---|---|---|
| mean | 3.3108071 | 0.1841048 | 49.318223 | 0.3968724 | 0.5540317 | 0.1712917 | 0.2692573 | 0.709278 |
| sd | 0.3046965 | 0.0714864 | 7.669841 | 0.0653765 | 0.1321647 | 0.0308491 | 0.0416688 | 0.067001 |
## Warning: Removed 1 rows containing non-finite values (stat_density).
All forecasts based on stochastic model with mean value of estimated parameter distributions as input
Demonstrating model fit against data, for availble variables:
Plotting model fit against data across all variables, only across available data time window
Plotting model fit against data across all variables, across full epidemic time course
Plotting total number at any point in time in Hospital, ICU, Ventilation
If everything continues as is, model projections forecast that:
The black lines in this plot indicates capacity
In this section we demonstrate projections for Hospitalization (H), ICU (Q), and Ventilation (V) needs given the mean and 95% upper and lower confidence bounds around each parameter estimate
Start time = mean (49.3182228)
Start time = upper 95% CI (64.3511112)
Start time = lower 95% CI (34.2853345)
Start time = combined mean, upper, and lower 95% CI
R0 = mean (3.3108071)
R0 = upper 95% CI (3.9080122)
R0 = lower 95% CI (2.7136019)
R0 = combined mean, upper, and lower 95% CI
A1. Calculating Pr(H), Pr(Q), Pr(H), based on age, gender, and population prevalences of risk factors A2. Specification of stochastic model
| Age | Sex | Smoking | Comorbidity |
|---|---|---|---|
| 0-19 | Female/Male | No | None |
| 20-44 | Female | No | None |
| 45-64 | Female | No | None |
| 65+ | Female | No | None |
| 20-44 | Male | No | None |
| 45-64 | Male | No | None |
| 65+ | Male | No | None |
| 20-44 | Female | Yes | None |
| 45-64 | Female | Yes | None |
| 65+ | Female | Yes | None |
| 20-44 | Male | Yes | None |
| 45-64 | Male | Yes | None |
| 65+ | Male | Yes | None |
| 20-44 | Female | No | Yes |
| 45-64 | Female | No | Yes |
| 65+ | Female | No | Yes |
| 20-44 | Male | No | Yes |
| 45-64 | Male | No | Yes |
| 65+ | Male | No | Yes |
| 20-44 | Female | Yes | Yes |
| 45-64 | Female | Yes | Yes |
| 65+ | Female | Yes | Yes |
| 20-44 | Male | Yes | Yes |
| 45-64 | Male | Yes | Yes |
| 65+ | Male | Yes | Yes |
| age.0.19 | age.20.44 | age.45.64 | age.65 | gender.Male | smoker | diabetes | hypertension | copd | coronary | |
|---|---|---|---|---|---|---|---|---|---|---|
| Antelope Valley | 0.27 | 0.32 | 0.31 | 0.10 | 0.49 | 0.18600 | 0.13100 | 0.30700 | 0.09000 | 0.30300 |
| San Fernando | 0.22 | 0.31 | 0.34 | 0.13 | 0.49 | 0.11200 | 0.10100 | 0.24200 | 0.07700 | 0.24700 |
| San Gabriel | 0.22 | 0.31 | 0.33 | 0.14 | 0.49 | 0.09600 | 0.11000 | 0.25500 | 0.05700 | 0.27700 |
| Metro | 0.20 | 0.36 | 0.33 | 0.12 | 0.51 | 0.13300 | 0.12100 | 0.25000 | 0.06000 | 0.28900 |
| West | 0.16 | 0.35 | 0.33 | 0.16 | 0.49 | 0.07500 | 0.06300 | 0.19600 | 0.05900 | 0.24800 |
| South | 0.29 | 0.34 | 0.28 | 0.08 | 0.49 | 0.12500 | 0.14700 | 0.25900 | 0.08500 | 0.26500 |
| East | 0.26 | 0.33 | 0.30 | 0.12 | 0.49 | 0.09300 | 0.11400 | 0.23200 | 0.04900 | 0.24900 |
| South Bay | 0.23 | 0.31 | 0.33 | 0.13 | 0.49 | 0.12400 | 0.12500 | 0.27600 | 0.06900 | 0.29000 |
| LA County | 0.23 | 0.33 | 0.32 | 0.12 | 0.50 | 0.11254 | 0.11315 | 0.24999 | 0.06663 | 0.26804 |
| Pr | age.0.19 | Age20.44 | Age45.64 | Age65. | SexMale | SmokingYes | ComorbidityYes |
|---|---|---|---|---|---|---|---|
| 0.025 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.103 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.146 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0.204 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0.105 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
| 0.149 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0.208 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0.173 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
| 0.238 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0.319 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 0.176 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
| 0.242 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
| 0.323 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0.161 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0.223 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0.300 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0.164 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0.227 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0.305 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0.259 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0.343 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0.439 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
| 0.264 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
| 0.348 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0.444 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0.025 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0.025 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Pr | age.0.19 | Age20.44 | Age45.64 | Age65. | SexMale | SmokingYes | ComorbidityYes |
|---|---|---|---|---|---|---|---|
| 0.000 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.202 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.259 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0.325 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0.241 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
| 0.305 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0.377 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0.325 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
| 0.399 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0.478 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 0.377 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
| 0.454 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
| 0.535 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0.217 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0.277 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0.345 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0.259 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0.325 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0.399 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0.346 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0.421 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0.501 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
| 0.399 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
| 0.478 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0.558 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0.000 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0.000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Pr | age.0.19 | Age20.44 | Age45.64 | Age65. | SexMale | SmokingYes | ComorbidityYes |
|---|---|---|---|---|---|---|---|
| 0.000 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.048 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.100 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0.197 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0.050 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
| 0.104 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0.204 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0.099 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
| 0.195 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0.348 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 0.103 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
| 0.202 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
| 0.358 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0.053 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0.110 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0.214 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0.055 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0.115 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0.222 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0.109 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0.212 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0.372 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
| 0.113 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
| 0.220 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0.383 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0.000 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0.000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Antelope Valley | San Fernando | San Gabriel | Metro | West | South | East | South Bay | LA County | age.0.19 | Age20.44 | Age45.64 | Age65. | SexMale | SmokingYes | ComorbidityYes |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.093 | 0.125 | 0.080 | 0.126 | 0.114 | 0.117 | 0.102 | 0.087 | 0.095 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.093 | 0.125 | 0.080 | 0.126 | 0.114 | 0.117 | 0.102 | 0.087 | 0.095 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0.051 | 0.063 | 0.104 | 0.071 | 0.082 | 0.054 | 0.068 | 0.077 | 0.044 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0.007 | 0.023 | 0.028 | 0.011 | 0.028 | 0.014 | 0.012 | 0.019 | 0.012 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0.061 | 0.079 | 0.066 | 0.086 | 0.086 | 0.099 | 0.095 | 0.070 | 0.091 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
| 0.071 | 0.049 | 0.064 | 0.073 | 0.072 | 0.031 | 0.080 | 0.053 | 0.047 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0.015 | 0.005 | 0.012 | 0.009 | 0.019 | 0.005 | 0.010 | 0.017 | 0.009 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0.024 | 0.007 | 0.014 | 0.004 | 0.002 | 0.005 | 0.005 | 0.017 | 0.005 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
| 0.002 | 0.014 | 0.007 | 0.009 | 0.014 | 0.012 | 0.010 | 0.010 | 0.019 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| 0.000 | 0.002 | 0.002 | 0.007 | 0.000 | 0.000 | 0.000 | 0.002 | 0.000 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 0.010 | 0.014 | 0.005 | 0.013 | 0.009 | 0.007 | 0.010 | 0.010 | 0.014 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
| 0.015 | 0.012 | 0.007 | 0.007 | 0.012 | 0.005 | 0.007 | 0.012 | 0.012 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
| 0.002 | 0.000 | 0.000 | 0.002 | 0.005 | 0.002 | 0.000 | 0.002 | 0.002 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
| 0.093 | 0.049 | 0.066 | 0.042 | 0.054 | 0.073 | 0.063 | 0.062 | 0.072 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0.068 | 0.102 | 0.071 | 0.077 | 0.068 | 0.089 | 0.078 | 0.096 | 0.091 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0.022 | 0.021 | 0.038 | 0.033 | 0.030 | 0.021 | 0.029 | 0.038 | 0.033 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0.083 | 0.072 | 0.061 | 0.062 | 0.054 | 0.070 | 0.063 | 0.075 | 0.086 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0.093 | 0.081 | 0.106 | 0.077 | 0.086 | 0.063 | 0.075 | 0.087 | 0.102 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0.037 | 0.023 | 0.056 | 0.040 | 0.028 | 0.021 | 0.036 | 0.041 | 0.014 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0.017 | 0.007 | 0.005 | 0.007 | 0.007 | 0.016 | 0.012 | 0.002 | 0.019 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0.017 | 0.009 | 0.009 | 0.004 | 0.005 | 0.021 | 0.002 | 0.017 | 0.009 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0.007 | 0.005 | 0.005 | 0.004 | 0.014 | 0.005 | 0.005 | 0.007 | 0.002 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
| 0.012 | 0.009 | 0.002 | 0.018 | 0.005 | 0.009 | 0.007 | 0.014 | 0.005 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
| 0.020 | 0.014 | 0.007 | 0.018 | 0.009 | 0.016 | 0.007 | 0.014 | 0.016 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0.005 | 0.002 | 0.002 | 0.009 | 0.002 | 0.002 | 0.005 | 0.002 | 0.007 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0.041 | 0.035 | 0.054 | 0.024 | 0.040 | 0.054 | 0.061 | 0.046 | 0.053 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0.041 | 0.053 | 0.049 | 0.040 | 0.040 | 0.070 | 0.054 | 0.036 | 0.047 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Pr(H) | Pr(Q) | Pr(D) | |
|---|---|---|---|
| Antelope Valley | 0.162 | 0.243 | 0.088 |
| San Fernando | 0.149 | 0.225 | 0.081 |
| San Gabriel | 0.160 | 0.238 | 0.092 |
| Metro | 0.156 | 0.237 | 0.089 |
| West | 0.153 | 0.234 | 0.089 |
| South | 0.145 | 0.214 | 0.076 |
| East | 0.147 | 0.223 | 0.080 |
| South Bay | 0.165 | 0.246 | 0.094 |
| LA County | 0.155 | 0.233 | 0.083 |
r_output(readLines(path_seihqdr_model))
## ```r
##
## # TRANSITION EQUATIONS
##
## ## Core equations for transitions between compartments:
## update(S) <- S - n_SE
## update(E) <- E + n_SE - n_Eout
## update(I) <- I + n_EoutI - n_Iout
## update(A) <- A + n_EoutA - n_AR
## update(H) <- H + n_IoutH - n_Hout
## update(Q) <- Q + n_HoutQ - n_Qout
## update(D) <- D + n_QoutD
## update(R) <- R + n_IoutR + n_HoutR + n_QoutR + n_AR
##
## ## Htot = H + Q
## update(Htot) <- H + Q + n_IoutH - n_HoutR - n_Qout # Htot represents all in Hospital: Non-ICU + ICU
##
## ## Ventilators (tracking as frac of Q, do not go to other compartments)
## update(V) <- p_QV*Q #V + n_QV - n_Vout
##
## ## Tracking cumulative numbers in compartments:
## update(Idetectcum) <- Idetectcum + n_EoutI
## update(Itotcum) <- Itotcum + n_Eout
## update(Htotcum) <- Htotcum + n_IoutH #Htotcum represents cumulative of all in Hospital: Non-ICU + ICU
## update(Qcum) <- Qcum + n_HoutQ
## update(Vcum) <- p_QV*Qcum #Vcum + n_QV
##
## ## New daily numbers
## output(I_detect_new) <- n_EoutI
## output(I_tot_new) <- n_Eout
## output(H_new) <- n_IoutH
## output(Q_new) <- n_HoutQ
## output(D_new) <- n_QoutD
## #output(d_EI_rand) <- d_EI
##
## ####################################################################################
##
## # PROBABILITIES
##
## ## Individual probabilities of transition:
## p_SE <- 1 - exp(-(Beta * (I+A)) / N) # S to E
## p_Eout <- 1 - exp(-1/d_EI) # E to I
## p_Iout <- 1 - exp(-((Alpha/d_IH) + ((1-Alpha)/d_IR))) #exp(-((1/d_IH) + (1/d_IR))) # I to H and R
## p_Hout <- 1 - exp(-((Kappa/d_HQ) + ((1-Kappa)/d_HR))) #exp(-((1/d_HQ) + (1/d_HR))) # H to Q and R
## p_Qout <- 1 - exp(-((Delta/d_QD) + ((1-Delta)/d_QR))) #exp(-((1/d_QD) + (1/d_QR))) # Q to D and R
## p_AR <- 1 - exp(-1/d_IR)
## #p_Vout <- 1 - exp(-1/d_V) # Leaving V
##
##
##
## # RANDOM DRAWS FOR NUMBERS CHANGING BETWEEN COMPARTMENTS
## ## Draws from binomial and multinomial distributions for numbers changing between compartments:
##
## ### S to E
## n_SE <- rbinom(S, p_SE)
##
## ### E to I and A
## n_Eout <- rbinom(E, p_Eout)
## n_EoutIA[] <- rmultinom(n_Eout, p_EoutIA)
## p_EoutIA[1] <- r
## p_EoutIA[2] <- 1-r
## dim(p_EoutIA) <- 2
## dim(n_EoutIA) <- 2
## n_EoutI <- n_EoutIA[1]
## n_EoutA <- n_EoutIA[2]
##
## ### A to R
## n_AR <- rbinom(A, p_AR)
##
## ### I to H and R
## n_Iout <- rbinom(I, p_Iout) # Total no. leaving I
## n_IoutHR[] <- rmultinom(n_Iout, p_IoutHR) # Divide total no. leaving I into I->H and I->R
## p_IoutHR[1] <- Alpha #(Alpha/d_IH)/((Alpha/d_IH) + ((1-Alpha)/d_IR)) # Goes to H and R with relative rates
## p_IoutHR[2] <- 1-Alpha #((1-Alpha)/d_IR)/((Alpha/d_IH) + ((1-Alpha)/d_IR)) # 1-p_IoutHR[1]
## dim(p_IoutHR) <- 2
## dim(n_IoutHR) <- 2
## n_IoutH <- n_IoutHR[1] # Total no. I->H
## n_IoutR <- n_IoutHR[2] # Total no. I->R
##
## ### H to Q and R
## n_Hout <- rbinom(H, p_Hout)
## n_HoutQR[] <- rmultinom(n_Hout, p_HoutQR)
## p_HoutQR[1] <- Kappa #(Kappa/d_HQ)/((Kappa/d_HQ) + ((1-Kappa)/d_HR))
## p_HoutQR[2] <- 1-Kappa #((1-Kappa)/d_HR)/((Kappa/d_HQ) + ((1-Kappa)/d_HR))
## dim(p_HoutQR) <- 2
## dim(n_HoutQR) <- 2
## n_HoutQ <- n_HoutQR[1]
## n_HoutR <- n_HoutQR[2]
##
## ### Q to D and R
## n_Qout <- rbinom(Q, p_Qout)
## n_QoutDR[] <- rmultinom(n_Qout, p_QoutDR)
## p_QoutDR[1] <- Delta #(Delta/d_QD)/((Delta/d_QD) + ((1-Delta)/d_QR))
## p_QoutDR[2] <- 1-Delta #((1-Delta)/d_QR)/((Delta/d_QD) + ((1-Delta)/d_QR))
## dim(p_QoutDR) <- 2
## dim(n_QoutDR) <- 2
## n_QoutD <- n_QoutDR[1]
## n_QoutR <- n_QoutDR[2]
##
## ### Q to V and Vout
## #n_QV <- rbinom(Q, p_QV)
## #n_Vout <- rbinom(V, p_Vout)
##
## ######################################################################
##
## # TOTAL POPULATION SIZE
## N <- S + E + I + A + H + Q + D + R
##
## ######################################################################
##
## # INITIAL STATES
## ## Core compartments
## initial(S) <- S_ini
## initial(E) <- E_ini
## initial(I) <- 0
## initial(A) <- 0
## initial(H) <- 0
## initial(Q) <- 0
## initial(D) <- 0
## initial(R) <- 0
## initial(V) <- 0
## initial(Htot) <- 0
##
## ## Cumulative counts
## initial(Idetectcum) <- 0
## initial(Itotcum) <- 0
## initial(Htotcum) <- 0
## initial(Qcum) <- 0
## initial(Vcum) <- 0
##
## ######################################################################
##
## # USER DEFINED PARAMETERS
## ## Default in parentheses:
##
## ### Initial conditions
## S_ini <- user(1e7) # susceptibles
## E_ini <- user(10) # infected
##
## ### Parameters - random
## #d_EI <- runif(3, 8)
##
## ### Parameters - fixed
## d_EI <- user(5.2) #days between exposure and infectivity (incubation period)
## d_IH <- user(10) #days between illness onset and hospitalization
## d_IR <- user(7) #days between illness onset and recovery (hospitalization not required)
## d_HQ <- user(1) #days between hospitalization start and ICU
## d_HR <- user(12) #days in hospital (ICU not required)
## d_QD <- user(8) #days in ICU before death (given death)
## d_QR <- user(7) #days in ICU before recovery (given recovery)
## #d_V <- user(3) #days on ventilator (within ICU)
##
## ### Parameters - weighted average risk probabilities: input from JAM + population prevalence
## Alpha <- user(0.14) #probability infected (I) requires hospitalization (vs. recovers)
## Kappa <- user(0.23) #probability hospitalized (H) requires ICU (vs. recovers)
## Delta <- user(0.06) #probability ICU (Q) patient dies
## p_QV <- user(0.667) #probability in ICU and requires ventilation
## r <- user(0.25)
##
## ### Other variables
## #R0 <- user(2.2) #Current estimates from other models
##
## ### Parameters - calculated from inputs
## #Br <- R0 * ( 1 / ( (r/ ((Alpha/d_IH) + ((1-Alpha)/d_IR))) + (1-r)*d_IR ))
##
##
##
## #########################################
## ### TIME VARYING BETA (INTERPOLATION) ###
## #########################################
##
## Beta <- interpolate(Beta_t, Beta_y,"linear")
##
## Beta_t[] <- user()# R0 * ((Alpha/d_IH)+((1-Alpha)/d_IR))
## Beta_y[] <- user()
## dim(Beta_t) <- user()
## dim(Beta_y) <- user()
##
##
##
## ```